<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Update Word</title>
<meta th:include="/admin/head :: header"></meta>
</head>

<style>
body {
	background: #ededed;
}
#toolbar{
	float:right;
	margin:5px;
	padding: 5px;
}

#update{
	margin: 0 20px;
}

</style>

<body>
	<div class="header">
		<h1 class="page-header">
			单词管理 <small></small>
		</h1>
		<ol class="breadcrumb">
			<li><a href="/admin/word/word-list">主页</a></li>
			<li><a href="/admin/word/word-list">单词管理</a></li>
			<li class="active">数据</li>
		</ol>
	</div>
	<div id="page-inner">
		<div class="row">
			<div class="col-md-12">
				<!-- Advanced Tables -->
				<div class="panel panel-default">
					<div class="panel-heading">单词表</div>
					<div class="panel-body">
						<div class="table-responsive">
							<table class="table table-striped table-bordered table-hover"
								id="table_dataTable">
								<thead>
									<tr>
										<th>单词标志</th>
										<th>文件名</th>
										<th>en</th>
										<th>zh-rCN</th>
										<th>zh</th>
										<th>fr</th>
										<th>创建时间</th>
										<th>操作</th>
									</tr>
								</thead>
							</table>
						</div>

					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	
	<script>
	//<![CDATA[
		 $(document).ready(function(){
			$.extend(true, $.fn.dataTable.defaults, {
	        	language: {
       		    	"sProcessing": "处理中...",
       		    	"sLengthMenu": "显示 _MENU_ 项结果",
       		      	"sZeroRecords": "没有匹配结果",
       		        "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
       		        "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
       		        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
       		        "sInfoPostFix": "",
       		        "sSearch": "搜索:",
       		        "sUrl": "",
       		        "sEmptyTable": "表中数据为空",
       		        "sLoadingRecords": "载入中...",
       		        "sInfoThousands": ",",
       		        "oPaginate": {
       		            "sFirst": "首页",
       		            "sPrevious": "上页",
       		            "sNext": "下页",
       		            "sLast": "末页"
       		        },
       		        "oAria": {
       		            "sSortAscending": ": 以升序排列此列",
       		            "sSortDescending": ": 以降序排列此列"
       		        }
       			},
       			dom: 'l<"#toolbar">rtip'
			});
			 
        	$("#table_dataTable").DataTable({
            serverSide: true,//分页，取数据等等的都放到服务端去
            processing: true,//载入数据的时候是否显示“载入中”
            order: [[ 6, "desc" ]],
            columnDefs:[{
               	orderable:false,
                targets:3
            }],
        	ajax: {
        		url:"/admin/word/getUpdateWord",
        		dataSrc: function(json){
        			if(!json.data)
        				json.data=[];
        			console.log(json);
        			return json.data;
        		},
        		data:function(data){
        			console.log(data);
        			var orderColumn = data.order[0].column;
        			var orderWay =  data.order[0].dir;
        			var orderBy  = data.columns[orderColumn].data+" "+orderWay;

        			data.orderBy = orderBy;

        			console.log(orderBy);
        		}
        	},
        	columns:[
        		{data:'wordId'},
        		{data:'fileName'},
        		{data:'en'},
        		{data:'zh_rCN'},
        		{data:'zh'},
        		{data:'fr'},
        		{data:'createTime',render:function(data,type,row,meta){
        			return (new Date(data)).format("yyyy-MM-dd hh:mm:ss");
        		}}
        	],
        	columnDefs:[{
        		targets:7,
        		data:null,
        		render:function(data, type, row){
        			var id = row.wordId;
        			var html = '<a type="button" class="btn btn-primary" href="/admin/word/update-word-edit-index?wordId='+id+'">编辑</a>';
        			html+="&nbsp;&nbsp;";
        			html +='<a type="button" class="btn btn-danger">删除</a>';
        			return html;
        		}
        	}],
        	initComplete:function(){
                 $("#toolbar").append('<a class = "btn btn-success" type="button" id="update" href="/admin/word/update-word-update">更新</a>');
                 $("#toolbar").append('<a class = "btn btn-warning" type="button" id="commit" href="/admin/word/update-word-commit">提交</a>');
        	}
        	});
        });
	//]]>
	</script>

</body>
</html>